<?php

namespace App\Providers;

use App\Models\Master;
use App\Observers\MasterObserver;
use App\Services\IAreaService;
use App\Services\ICacheService;
use App\Services\ICookieService;
use App\Services\IFinanceService;
use App\Services\IMasterLogService;
use App\Services\IMasterService;
use App\Services\IMerchantService;
use App\Services\IMobileService;
use App\Services\Impl\AreaServiceImpl;
use App\Services\Impl\CacheServiceImpl;
use App\Services\Impl\CookieServiceImpl;
use App\Services\Impl\FinanceServiceImpl;
use App\Services\Impl\MasterLogServiceImpl;
use App\Services\Impl\MasterServiceImpl;
use App\Services\Impl\MerchantServiceImpl;
use App\Services\Impl\MobileServiceImpl;
use App\Services\Impl\OrderServiceImpl;
use App\Services\Impl\PayServiceImpl;
use App\Services\Impl\QiniuStorageServiceImpl;
use App\Services\Impl\RefundServiceImpl;
use App\Services\Impl\SessionServiceImpl;
use App\Services\Impl\StatisticServiceImpl;
use App\Services\Impl\SystemServiceImpl;
use App\Services\Impl\WalletServiceImpl;
use App\Services\Impl\WeixinQyServiceImpl;
use App\Services\Impl\WeixinServiceImpl;
use App\Services\IOrderService;
use App\Services\IPayService;
use App\Services\IRefundService;
use App\Services\ISessionService;
use App\Services\IStatisticService;
use App\Services\IStorageService;
use App\Services\ISystemService;
use App\Services\IWalletService;
use App\Services\IWeinxinQyService;
use App\Services\IWeixinService;
use Illuminate\Support\ServiceProvider;
use View;

class ProjectServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        View::composer('*', function (\Illuminate\View\View $view) {
            $view->with('request',request());
            $view->with('session',request()->getSession());
        });
        View::share('titlePrefix','乐帮到家师傅端');

        Master::observe(MasterObserver::class);
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        /**
         * 统计服务
         */
        $this->app->singleton(IStatisticService::class, StatisticServiceImpl::class);
        /**
         * 订单服务
         */
        $this->app->singleton(IOrderService::class, OrderServiceImpl::class);
        $this->app->singleton(IRefundService::class, RefundServiceImpl::class);
        /**
         * 系统服务
         */
        $this->app->singleton(IMobileService::class, MobileServiceImpl::class);
        $this->app->singleton(ISystemService::class, SystemServiceImpl::class);
        $this->app->singleton(IAreaService::class, AreaServiceImpl::class);
        $this->app->singleton(ISessionService::class, SessionServiceImpl::class);
        $this->app->singleton(ICookieService::class, CookieServiceImpl::class);
        $this->app->singleton(ICacheService::class, CacheServiceImpl::class);
        $this->app->singleton(IStorageService::class, QiniuStorageServiceImpl::class);
        $this->app->singleton(IPayService::class, PayServiceImpl::class);
        /**
         * 用户服务
         */
        $this->app->singleton(IMasterService::class, MasterServiceImpl::class);
        $this->app->singleton(IWalletService::class, WalletServiceImpl::class);
        $this->app->singleton(IMerchantService::class, MerchantServiceImpl::class);
        $this->app->singleton(IMasterLogService::class, MasterLogServiceImpl::class);
        $this->app->singleton(IFinanceService::class, FinanceServiceImpl::class);
        /**
         * 微信平台服务
         */
        $this->app->singleton(IWeixinService::class, WeixinServiceImpl::class);
        $this->app->singleton(IWeinxinQyService::class, WeixinQyServiceImpl::class);
    }
}
